<?php if(!defined('CALL')) exit('No direct script access allowed');

include_once('lib/xtemplate.class.php');

class vMenus
{
	private $xtpl = null;
	
	public function gen_plans_menu($actor, $user)
	{
		if($this->xtpl == null)
			$this->xtpl = new XTemplate('xtpl/menus.xtpl');
		$this->xtpl->assign('root', ROOT_URL);
		$this->xtpl->assign('user_id', $user->id);
		$this->xtpl->assign('actor_id', $actor->id);
		$this->xtpl->assign('city_id', $_SESSION['city_id']);

		if($_SESSION['city_id'] == 0)
			$this->xtpl->assign('city', 'во всех городах');
		else
			$this->xtpl->assign('city', 'в г.'.$_SESSION['city']);

		$this->xtpl->assign('date', $_SESSION['date']);
		
		$this->xtpl->assign('mi_'.$_SESSION['categ'], 'class="current"');
		
		$this->xtpl->parse('root.plans_menu');
		return $this->xtpl->text('root.plans_menu');
	}
	
	public function gen_message_menu($actor, $user)
	{
		if($this->xtpl == null)
			$this->xtpl = new XTemplate('xtpl/menus.xtpl');
		$this->xtpl->assign('root', ROOT_URL);
		$this->xtpl->assign('user_id', $user->id);
		$this->xtpl->assign('actor_id', $actor->id);
		$this->xtpl->assign('city_id', $_SESSION['city_id']);

		$this->xtpl->assign('mi_'.$_SESSION['categ'], 'class="current"');
		
		$this->xtpl->parse('root.message_menu');
		return $this->xtpl->text('root.message_menu');
	}
	
	public function gen_search_form()
	{
		if($this->xtpl == null)
			$this->xtpl = new XTemplate('xtpl/menus.xtpl');
		
		$this->xtpl->assign('root', ROOT_URL);
		$this->xtpl->assign('user_id', $user->id);
		$this->xtpl->assign('actor_id', $actor->id);
		$this->xtpl->assign('city_id', $_SESSION['city_id']);
		
		$search_empty = 'Поиск людей и событий…';		
		$this->xtpl->assign('search_empty', $search_empty);
		$search = (empty($_POST['search'])) ? $search_empty : $_POST['search'];
		$this->xtpl->assign('search', $search);
		
		$this->xtpl->parse('root.search');
		return $this->xtpl->text('root.search');
	}
	
	public function gen_calendar_holder()
	{
		if($this->xtpl == null)
			$this->xtpl = new XTemplate('xtpl/menus.xtpl');
		$this->xtpl->parse('root.date_picker');
		return $this->xtpl->text('root.date_picker');
	}

}